package cn.edu.guet.springmvcdemo.controller;

import cn.edu.guet.springmvcdemo.model.User;
import cn.edu.guet.springmvcdemo.mvc.annotation.Controller;
import cn.edu.guet.springmvcdemo.mvc.annotation.RequestMapping;
import cn.edu.guet.springmvcdemo.service.UserService;

import java.util.List;

/*
 *   @Studio:CHJY · 源梦科技
 *   @Author:lzl
 *   @Ide:IntelliJ IDEA
 *   @Creation time:2021/7/1 20:08
 */
@Controller
public class UserController {

    UserService userService;

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    @RequestMapping("home.do")
    public String home(){
        return "forward:WEB-INF/views/viewUser.jsp";
    }

    @RequestMapping("deleteUser.do")
    public void deleteUser(String userId){
        userService.deleteUser(userId);
    }
    @RequestMapping("viewUser.do")
    public List<User> viewUser(){
        return userService.viewAllUser();
    }
}
